package com.zlsy.springbootdemo.strategy.example1.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author zhouliang
 * @date 2021/1/19 16:03
 */
@Getter
@AllArgsConstructor
public enum StrategyEnum {
  /** 测试策略模式例子1 */
  ADD("add", "加"),
  MULTIPLY("Multiply", "乘"),
  SUBTRACT("Subtract", "减"),
  /** ===============Order====================* */
  /** 模拟订单操作 */
  CREATE_ORDER("create", "创建订单"),
  CANCEL_ORDER("cancel", "取消订单"),
  QUERY_ORDER("query", "查询订单");

  private String code;
  private String desc;

  public static StrategyEnum find(final String code) {
    return Arrays.stream(values())
        .filter(value -> value.getCode().equals(code))
        .findFirst()
        .orElse(null);
  }
}
